﻿using System;
using System.Drawing;
using System.Windows.Forms;
using IiiToolkitMain.Common.Dto;

namespace IiiToolkitMain.Controls
{
  
    public partial class VideoPlayer : UserControl
    {
        public enum PlayStatus
        {
            Playing,
            Stoped,
            Pause
        }
        public event VideoPlayerSeleted OnVideoPlayerSelected;
        public event VideoPlayerLevelChanged OnVideoPlayerLevelChanged;
        public event VideoPlayerStatusChanged OnVideoPlayerStatusChanged;

        private int _videoLevel;

        public int VideoLevel
        {
            get
            {
                return _videoLevel;
            }
            set
            {
                if (_videoLevel != value)
                {
                    if (OnVideoPlayerLevelChanged != null)
                    {
                        OnVideoPlayerLevelChanged(this,new VideoPlayerEventArgs());
                    }
                }
                this._videoLevel = value;
            }
        }

        private PlayStatus _playStatus;

        public PlayStatus Status
        {
            get { return _playStatus; }
            set
            {
                if (_playStatus != value)
                {
                    if (OnVideoPlayerStatusChanged != null)
                    {
                        OnVideoPlayerStatusChanged(this,new VideoPlayerEventArgs());
                    }   
                }
                this._playStatus = value;
            }
        }

        public IntPtr SessionId { get; set; }
        public CameraItem CameraItem { get; set; }
        public VideoPlayer()
        {
          
            InitializeComponent();

            this.VideoLevel = 2;
            this.Status = PlayStatus.Stoped;
        }

        public IntPtr PlayerHandle
        {
            get { return this.playerBox.Handle; }
        }

        

        private void pictureBox1_Click(object sender, System.EventArgs e)
        {
            if(OnVideoPlayerSelected != null)
                OnVideoPlayerSelected(this,new VideoPlayerEventArgs());
        }
        public Color SelectedColor { get; set; }
        

        public void ClearSelectedColor()
        {
            this.BackColor = Color.LightGray;
        }
        public void SetSelectedColor()
        {
            //ControlPaint.DrawBorder(this.CreateGraphics(), this.ClientRectangle, borderColor, ButtonBorderStyle.Solid);
            this.BackColor = SelectedColor;
        }

        public void Stop()
        {
            this.playerBox.Refresh();
        }
    }
}
